<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>无标题文档</title>
  <link href="../../css/style.css" rel="stylesheet" type="text/css" />
  <script type="text/javascript" src="../../js/jquery.js"></script>
  <script type="text/javascript" src="../../js/axios.js"></script>
  <script type="text/javascript" src="../../js/api.js"></script>
  <link rel="stylesheet" href="../../layui/css/layui.css">
  <script type="text/javascript" src="../../layui/layui.js"></script>
</head>

<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li>数据统计</li>
    <li>厂商采购统计</li>
    <li>基本内容</li>
  </ul>
</div>
<div class="rightinfo">
  <form  id="search_condition" method="post">
    <ul class="tools">
      <li> 所属区域：
        <select name="province" id="province">
          <option value="0">请选择省份</option>
          <option>北京</option>
          <option>江苏</option>
          <option>天津</option>
        </select>
        <select name="city" id="city">
          <option value="0">请选择城市</option>
          <option>北京</option>
          <option>南京</option>
          <option>天津</option>
        </select>
      </li>
      <li> 厂商名称:
        <input name="firmnamelike" type="text"/>
      </li>
      <li> 时间:
        <input name="startime" type="text" />-<input  name="endtime" type="text" />
      </li>

      <li class="subBut" id="subBut" type="button" onclick="load()"><img src="../../images/t06.png" />查询</li>
    </ul>
    <table class="tablelist">
      <thead>
        <tr>
          <th>序号</th>
          <th>厂商名称</th>
          <th>负责人</th>
          <th>所属区域</th>
          <th>采购单数量</th>
          <th>金额</th>
          <th>采购单明细</th>
        </tr>
      </thead>
      <tbody id="tb">
       <!-- <tr>
          <td>1</td>
          <td>阿里巴巴</td>
          <td>马云</td>
          <td>江苏南京</td>
          <td>5</td>
          <td>￥9,876,582</td>
          <td>
          	<a href="purchaseView.html" class="tablelink">查看详情</a>
          </td>
        </tr>-->
      </tbody>
    </table>
    <div class="pagin" id="page">
      <!--<div class="message">共<i class="blue">1256</i>条记录，当前显示第&nbsp;<i class="blue">2&nbsp;</i>页</div>
      <ul class="paginList">
        <li class="paginItem"><a href="javascript:;"><span class="pagepre"></span></a></li>
        <li class="paginItem"><a href="javascript:;">1</a></li>
        <li class="paginItem current"><a href="javascript:;">2</a></li>
        <li class="paginItem"><a href="javascript:;">3</a></li>
        <li class="paginItem"><a href="javascript:;">4</a></li>
        <li class="paginItem"><a href="javascript:;">5</a></li>
        <li class="paginItem more"><a href="javascript:;">...</a></li>
        <li class="paginItem"><a href="javascript:;">10</a></li>
        <li class="paginItem"><a href="javascript:;"><span class="pagenxt"></span></a></li>
      </ul>-->
    </div>
  </form>
</div>
<script type="text/javascript">
  var condition;
  var totalcount;
  var pagesize = 8;
  var pagenum = 1;

  $(function () {
    load();
    addressMenuInitOfDefault($("#province"), $("#city"), 0, 0)
  })
  function load() {
    condition = $("#search_condition").serializeArray();

    for (let i = condition.length;i>3;i--){
      let v = condition[i-1];
      if (v.value==""){
        // condition.pop(); //pop 删除数组最后一个元素
        condition.splice(i-1,1)
      }
    }

    let str = "";
    axiosJson("get", "/census/queryProductInfo", condition, {pagenum:pagenum,pagesize:pagesize}).then(res => {
      /*console.log(res)*/
      totalcount = res.data.totalCount;
      pagesize = res.data.pageSize;
      pagenum = res.data.pageNum;

      res = res.data;

      for (let i = 0; i < res.data.length; i++) {
        var rel = res.data[i];
        var firmid = res.data[i].firmid;
        /*console.log(customid)*/
        str += '<tr>\n' +
               '      <td>'+(i+1)+'</td>\n' +
               '      <td>'+rel.firmname+'</td>\n' +
               '      <td>'+rel.firmfounder+'</td>\n' +
               '      <td>'+rel.provincename+rel.cityname+'</td>\n' +
               '      <td>'+rel.count+'</td>\n' +
               '      <td>￥'+rel.money+'</td>\n' +
               '      <td>\n' +
               '        <a href="purchaseView.html?id='+rel.firmid+'" class="tablelink">查看详情</a>\n' +
               '      </td>\n' +
               '</tr>'
      }
      $("#tb").html(str);
      $('.tablelist tbody tr:odd').addClass('odd');

      /*分页会了，经过李哥的教导*/
      layui.use("laypage", function () {
        var laypage = layui.laypage;
        laypage.render({
          elem: "page",                       //页码所放的位置，div标签的id
          count: totalcount,             	    //总记录数
          limit: pagesize,                    //每页的数据
          limits: [5, 8, 12],                 //每页可访问的数据量，可供用户选择
          curr: pagenum,                      //当前页
          layout: ['prev', 'page', 'next', 'limit', 'count'],
          //layout是改变分页布局的变量 prev:上一页 page:页码 next:下一页 limit:改分页长度下拉框 count:显示数据总量
          jump: function (obj, first) {		//监听分页按钮，按下时被调用
            pagenum = obj.curr		//获取改变的分页信息
            pagesize = obj.limit
            if (!first) {
              load(pagenum, pagesize);	//重新调用自己的加载页面的函数
            }
          }
        })
      })
    })
  };



  /*function loadPurchaseInfo() {

    condition = $("#search_condition").serializeArray();
    console.log(condition)
    for (let i = condition.length;i>3;i--){
      // if (i==3 || i==4){
      let v = condition[i-1];
      if (v.value==""){
        // condition.pop(); //pop 删除数组最后一个元素
        condition.splice(i-1,1)
      }
      // console.log("value:"+v.value)
    }

    console.log(condition);
    let str = "";
    axiosJson("get","/census/queryProductInfo",condition,{pagenum:pagenum, pagesize:pagesize}).then(res => {
      /!*console.log(res)*!/

      res = res.data;
      pagesize=res.pageSize;
      pagenum=res.pageNum;
      totalcount=res.totalCount;
      for (let i = 0;i < res.data.length;i++){
        var rel = res.data[i];
        var firmid = res.data[i].firmid;
        str += '<tr>\n' +
               '      <td>'+(i+1)+'</td>\n' +
               '      <td>'+rel.firmname+'</td>\n' +
               '      <td>'+rel.firmfounder+'</td>\n' +
               '      <td>'+rel.provincename+rel.cityname+'</td>\n' +
               '      <td>'+rel.count+'</td>\n' +
               '      <td>￥'+rel.money+'</td>\n' +
               '      <td>\n' +
               '        <a href="purchaseView.html?id='+rel.firmid+'" class="tablelink">查看详情</a>\n' +
               '      </td>\n' +
               '</tr>'
      }
      $("#tb").html(str);
      /!*分页会了，经过李哥的教导*!/
      layui.use("laypage", function () {
        var laypage = layui.laypage;
        laypage.render({
          elem: "page",                       //页码所放的位置，div标签的id
          count: totalcount,             	    //总记录数
          limit: pagesize,                    //每页的数据
          limits: [5, 8, 12],                 //每页可访问的数据量，可供用户选择
          curr: pagenum,                      //当前页
          layout: ['prev', 'page', 'next', 'limit', 'count'],
          //layout是改变分页布局的变量 prev:上一页 page:页码 next:下一页 limit:改分页长度下拉框 count:显示数据总量
          jump: function (obj, first) {		//监听分页按钮，按下时被调用
            pagenum = obj.curr		//获取改变的分页信息
            pagesize = obj.limit
            if (!first) {
              loadPurchaseInfo(pagenum, pagesize);	//重新调用自己的加载页面的函数
            }
          }
        })
      })
    })
  };*/

  $('.tablelist tbody tr:odd').addClass('odd');
</script>
</body>
</html>
